class Actor;

class ConvexDesc
{
public:
	NxConvexMeshDesc* cxmd;
	NxConvexShapeDesc* cxsd;

	ConvexDesc(){cxmd=0;cxsd=0;}
	~ConvexDesc()
	{
		if(cxmd)delete cxmd;
		if(cxsd)delete cxsd;
	}
};

class PhysX
{
	// Physics
	NxPhysicsSDK*	PhysicsSDK;
	NxScene*			Scene;
public:

	PhysX(int mode);
	~PhysX();

	void Update(float twin);
	unsigned int GetCount();

	Actor* AddCapsule	(float radius,float height);
	Actor* AddCube		(float size);
	Actor* AddBox		(float sizex,float sizey,float sizez,int dynamic);
	Actor* AddPlane		(float nx,float ny,float nz);
	Actor* AddSphere	(float size);

	ConvexDesc* BuildConvexDesc(Surface *src);
	ConvexDesc* BuildConvexDesc(int cnt,Vector3D *vs);
	Actor* AddConvex (ConvexDesc *cd);

	void SetContactReport(NxUserContactReport *callback);
	void Collisions(int type1,int type2);

	unsigned int AddMaterial(float dfriction,float sfriction,float rest);

};

class Actor
{
	friend class PhysX;
	NxActor *act;
public:
	Actor(NxActor *a);
	~Actor();

	void AddForce(float x,float y,float z,int local);
	void AddImpulse(float x,float y,float z,int local);
	void AddTorque(float x,float y,float z,int local);
	void AddAngular(float x,float y,float z,int local);

	void EntityPosition(Entity *ent);
	void EntityAs(Entity *ent);
	void AsEntity(Entity *ent);

	void Position(float x,float y,float z);
	void Position(Entity *ent);
	void SetName(const char *aname);
	const char* GetName();

	void SetType(int tp);
	void SetUserData(void *data);

	void Damping(float value);
	void Damping(float angular,float linerial);

	void Mass(float value);

	void Accelerate(float value);
	void Accelerate(Actor *as, float value);

	void SetMaxAngularVelocity(float maxv);
};